import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:xindong/common/xindong_sezhi.dart';
import 'package:xindong/manager/xindong_page_singleton.dart';
import 'package:xindong/routes/call/controller/xindong_call_controller.dart';
import 'package:xindong/routes/call/controller/xindong_call_timer_ctr.dart';

class XinDongCallPoorView extends StatelessWidget {
  const XinDongCallPoorView({super.key});

  @override
  Widget build(BuildContext context) {
    return GetBuilder<XinDongCallTimerController>(builder: (controller) {
      if (controller.checkBalanceTime < 0) {
        return const SizedBox();
      }
      bool isConsumer = XinDongCallController.to.isConsumer;
      String timeText = controller.showBalanceTime;
      Color color = isConsumer ? DZColors.white : Colors.orange;
      return Container(
        padding: const EdgeInsets.only(left: 10, right: 10),
        decoration: BoxDecoration(color: DZColors.transparentButtonColor, borderRadius: BorderRadius.circular(16)),
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            const SizedBox(height: 10),
            Text(
              timeText,
              style: const TextStyle(color: DZColors.white, fontSize: 15, fontWeight: FontWeight.normal),
            ),
            const SizedBox(height: 5),
            Text(
              isConsumer ? "您的余额不足\n通话将结束" : "对方余额不足\n可提醒对方充值延长时间",
              textAlign: TextAlign.center,
              style: TextStyle(color: color, fontSize: 13, fontWeight: FontWeight.normal),
            ),
            SizedBox(height: isConsumer ? 10 : 0),
            isConsumer
                ? MaterialButton(
                    height: 32.0,
                    minWidth: 88.0,
                    elevation: 0,
                    textColor: Colors.white,
                    onPressed: () => XinDongPageSingleton.instance.toRechargeYeMian(),
                    shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(30.0)),
                    materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
                    color: DZColors.mainColor,
                    child: const Text(
                      "立即充值",
                      style: TextStyle(fontSize: 14, fontWeight: FontWeight.normal, height: 1.2),
                    ),
                  )
                : const SizedBox(),
            const SizedBox(height: 10),
          ],
        ),
      );
    });
  }
}
